﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using System.Configuration;

namespace Ks.Fs.Core.Common
{
    public class Config
    {
        static NameValueCollection appSettings = null;
        public static NameValueCollection AppSettings
        {
            get
            {
                if (appSettings == null)
                {
                    appSettings = ConfigurationManager.AppSettings;
                }
                return appSettings;
            }
        }

        public static string GetAppSettingByName(string key, string _default = "")
        {
            if (AppSettings.AllKeys.Contains(key))
            {
                return AppSettings[key];
            }
            //Log.Error(string.Format("Element with the {0} Web.Config/AppSetting", key));
            return _default;            
        }

        public static string RootPath
        {
            get
            {
                return GetAppSettingByName("ROOT_PATH");
            }
        }
        public static string ThumbFolderName
        {
            get
            {
                return GetAppSettingByName("ThumbFolderName");
            }
        }
        public static int ImageThumbWidth
        {
            get
            {
                return Convert.ToInt32(GetAppSettingByName("ImageThumbWidth"));
            }
        }
      

        public static string[] AllowFileExtentions
        {
            get
            {
                string afe = string.Empty;
                afe = GetAppSettingByName("ALLOW_EXTENTION",string.Empty);
                return afe.Split(',');
            }
        }

    }
}
